
import { inject, observer } from 'mobx-react';
import BusinessInfo from '../customer/BusinessInfo';
import { toJS } from "mobx";

@inject('businessCardStore')
@observer
class BusinessCard extends React.Component {

    componentWillReceiveProps(nextProps) {
        const oldData = this.props.data;
        const newData = nextProps.data;
        if (oldData !== newData) {
            const { businessCardStore } = nextProps;
            businessCardStore.getBusinessInfo(newData);
        }
    }

    componentDidMount() {
        const { businessCardStore } = this.props;
        const data = this.props.data
        businessCardStore.getBusinessInfo(data);
    }

    render() {
        const { businessCardStore } = this.props;
        const { businessInfoData } = businessCardStore;
        return (
            <div style={{height:'100%'}}>
                <BusinessInfo data={toJS(businessInfoData)} />
            </div>
        )
    }

}

export default BusinessCard;